import {SAVE_USERINFO,DELETE_USERINFO} from "../constant"
export const createSaveUserInfoAction = (value) => {
    // 一般最好在actionCreator里存localStorage
    // 存的一组一组的key，value字符串【注意存的时候是字符串】
    localStorage.setItem("user",JSON.stringify(value.user))   //因为user为对象，所以要转字符串
    localStorage.setItem("token",value.token)
    return {type:SAVE_USERINFO,data:value}
}

//创建一个清除用户信息的action
export const createDeleteUserInfoAction = () => {
    //清空localStorage
    localStorage.removeItem("user")
    localStorage.removeItem("token")
    return {type:DELETE_USERINFO}
}
